package eight.test_8_2;

import java.util.Scanner;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int h = scanner.nextInt();
            int a = scanner.nextInt();
            int H = scanner.nextInt();
            int A = scanner.nextInt();
            if(a >= H || A <= 0) {
                System.out.println(-1);
            } else {
                int count = 0;
                while (h > 0) {
                    int tmp = H;
                    while (h >0 && tmp > 0) {
                        tmp -= a;
                        if(tmp > 0) {
                            h -= A;
                        }
                    }
                    if(tmp <= 0 && h >= 0) {
                        count++;
                    }
                }
                System.out.println(count);
            }
        }
    }
}
